
package fhedu;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

import javax.microedition.lcdui.game.GameCanvas;

/**
 *
 * @author kUN
 */

public class menu extends GameCanvas{
    
    int rong=getWidth();
    int cao=getHeight();
    Image bgmenu;
    Image menu;
    int focus=0;
    CellMeNu mangmenu[]=new CellMeNu[5];
    Graphics g=getGraphics();
    Graphics gmenu;
  //  Ticker ticker=new Ticker("Xin chào: Bùi Thanh Minh. Bạn có 2 cập nhật mới. Chọn menu để xem cập nhật");
    menu()
    {
        super(false);
       // this.setTicker(ticker);
        this.setFullScreenMode(true);
       // gmenu.drawString(rong+"  "+ cao, 10, 10, Graphics.TOP|Graphics.LEFT);
        menu=Image.createImage(240,320);
        gmenu=menu.getGraphics();
        gmenu.setFont(MyFont.fontnhodam);
        try{
        bgmenu=Image.createImage("Image/bgmenu.png");
        gmenu.drawImage(bgmenu, 0, 0, Graphics.TOP|Graphics.LEFT);
        }catch(Exception e){};
        mangmenu[0]=new CellMeNu("Image/iclich.png", "Tra cứu lịch học");
        mangmenu[0].Draw(gmenu, 20, 160);
        mangmenu[1]=new CellMeNu("Image/iclich.png", "Tra cứu điểm thi");
        mangmenu[1].Draw(gmenu, 20, 181);
        mangmenu[2]=new CellMeNu("Image/iclich.png", "Xem thông báo");
        mangmenu[2].Draw(gmenu, 20, 202);
        mangmenu[3]=new CellMeNu("Image/iclich.png", "Giới thiệu");
        mangmenu[3].Draw(gmenu, 20, 223);
        mangmenu[4]=new CellMeNu("Image/iclich.png", "Thoát");
        mangmenu[4].Draw(gmenu, 20, 244);
        mangmenu[focus].FoCus(gmenu);
        g.drawImage(menu, 0, 0, Graphics.TOP|Graphics.LEFT);        
        flushGraphics();
        
    }
    void refresh(Graphics g)
    {
        g.drawImage(menu, 0, 0, Graphics.TOP|Graphics.LEFT);        
        flushGraphics();
    }
    public void keyPressed(int k)
    {
        switch(getGameAction(k))
        {
            case UP:
                if(focus>0)
                {
                mangmenu[focus].UnFocus(gmenu);
                mangmenu[focus-1].FoCus(gmenu);
                focus-=1;    
                this.refresh(g);
                }
                break;
            case DOWN:
                if(focus<4)
                {
                mangmenu[focus].UnFocus(gmenu);
                mangmenu[focus+1].FoCus(gmenu);
                focus+=1;    
                this.refresh(g);
                }
                break;
            case FIRE:
                if(focus==1)
                {
  
                   // FHEDU.display=null;
                bgmenu=null;
                menu=null;    
                g=null;
                gmenu=null;
                mangmenu=null;
                FHEDU.display.setCurrent(new XemDiem());
                }
                break;
        }
        
    }
    
}
